package com.hotelManagerSystem.util;

import org.apache.shiro.crypto.hash.SimpleHash;

import java.util.Random;

public class MD5Util {
    /*
     * 生成随机字符串
     * */
    public static String createRandomStr1(){
        int length=16;
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(62);
            stringBuffer.append(str.charAt(number));
        }
        return stringBuffer.toString();
    }
    /*
    * MD5加密
    * */
    public static String md5(String salt,String password){
        return new SimpleHash("MD5",password,salt,1024).toString();
    }

    public static void main(String[] args) {
        System.out.println(md5("x4Yi1DlB3BcrO6Wk", "123456"));
    }
}
